﻿@inject IOptionsSnapshot<SiteOptions> SiteOptions
@inject ITagService Service
@inject IDistributedCacheHelper CacheHelper

@{
    const string cacheKeyForTags = "_TagPartial";

    async Task<List<TagBrief>?> GetDataFromDb()
    {
        return await Service.GetTagsAsync(30);
    }

    var datas = await CacheHelper.GetOrCreateAsync(cacheKeyForTags,
        async e => await GetDataFromDb());
}

<div class="whitebg box tags">
    <div class="news-title">
        <h2>热门标签</h2>
        <span class="tab-a-more">
            <a href="/tag" title="更多">
                <i></i><i></i><i></i>
            </a>
        </span>
    </div>
    <ul>
        @foreach (var item in datas!)
        {
            <li>
                <a href="/tag/@item.Name" target="_blank" title="@item.Name">
                    @item.Name (@item.BlogCount)
                </a>
            </li>
        }
    </ul>
</div>